<?php

namespace common\models\db\tables;

use Yii;

/**
 * This is the model class for table "{{%categories}}".
 *
 * @property int $id
 * @property int|null $pid
 * @property int $cate_sort 排序
 * @property string $name 分类名
 * @property int $created_at
 * @property int $updated_at
 * @property int $status 200正常使用
 * @property int $is_danger 是否危险品
 * @property int $is_virtual 是否虚拟物品
 * @property int|null $created_by_adminer
 * @property int|null $updated_by_adminer
 */
class Categories extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%categories}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['pid', 'cate_sort', 'name', 'created_at', 'updated_at', 'status', 'is_danger', 'is_virtual', 'created_by_adminer', 'updated_by_adminer'], 'trim'],
            [['pid', 'cate_sort', 'created_at', 'updated_at', 'status', 'is_danger', 'is_virtual', 'created_by_adminer', 'updated_by_adminer'], 'integer'],
            [['name', 'created_at', 'updated_at'], 'required'],
            [['name'], 'string', 'max' => 180],
            [['pid', 'created_by_adminer', 'updated_by_adminer'], 'default', 'value' => null],
            [['cate_sort'], 'default', 'value' => 1],
            [['status'], 'default', 'value' => 200],
            [['is_danger', 'is_virtual'], 'default', 'value' => 2],
            [['name'], 'unique'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'pid' => Yii::t('app', 'Pid'),
            'cate_sort' => Yii::t('app', '排序'),
            'name' => Yii::t('app', '分类名'),
            'created_at' => Yii::t('app', 'Created At'),
            'updated_at' => Yii::t('app', 'Updated At'),
            'status' => Yii::t('app', '200正常使用'),
            'is_danger' => Yii::t('app', '是否危险品'),
            'is_virtual' => Yii::t('app', '是否虚拟物品'),
            'created_by_adminer' => Yii::t('app', 'Created By Adminer'),
            'updated_by_adminer' => Yii::t('app', 'Updated By Adminer'),
        ];
    }
}
